package AggregateFun;

import org.apache.flink.api.common.functions.AggregateFunction;
import org.apache.flink.api.java.tuple.Tuple3;

public class PriceAggregate implements AggregateFunction<Tuple3<String,Long,String>, Long, Long> {
    //初始化累加器为0
    @Override
    public Long createAccumulator() {
        return 0L; //D表示Double,L表示long
    }

    //把price往累加器上累加
    @Override
    public Long add(Tuple3<String,Long,String> value, Long accumulator) {
        return value.f1+accumulator;
    }

    //获取累加结果
    @Override
    public Long getResult(Long accumulator) {
        return accumulator;
    }

    //各个subTask的结果合并
    @Override
    public Long merge(Long a, Long b) {
        return a+b;
    }
}